Repository navigation
Fix bugs in packed ORAM with entries spanning several words - #1802
Merged
Merged
Conversation
Member
|
Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I found this when I wanted to store an array in each entry of a packed ORAM, which makes each entry span several words.
For such entries,
entries_per_elementis a fraction, soused_bits = entries_per_element * sum(entry_size)is a float, for example 30.0 forentry_size=(40, 40, 40)on a 64-bit ring.With
Scripts/compile-run.py -E ring,-E sy-rep-ringor-E rep-field, the following snippet raisesTypeError: 'float' object cannot be interpreted as an integerinrandom_block:With
-E rep-field, the following snippet raisesInvalid argument 0 "81.0" to instruction: reqbl 81.0:If
used_bitsis lower than the number of bits in a word, the compiler accepts a prime given with--primethat is too short for the words; the words then overflow, and reads return wrong values. For example, each word of the following snippet holds two 40-bit values, butused_bitsis 60.0. Compiled with--primeand run with-P, both set to the 80-bit prime2**79 + 23, the snippet prints1099511627752instead of1099511627775:With
sbitsvalues, the storage creates register types ofused_bitsbits, so packed circuit ORAM, for examplecircuit_oram.RecursiveCircuitIndexStructure, fails for these entries withTypeError: unsupported operand type(s) for <<: 'int' and 'float'.Fix
For entries spanning several words, the storage now receives the number of bits in each word,
sum(x)for eachxinsplit_sizes, instead ofused_bits, andrandom_initdraws exactly that many random bits for each word.Testing
Starting from these snippets, I varied the ORAM (linear, tree and path ORAM, with and without empty entries), the entry size (from one word to 96 words, with words of the same or of different sizes), the initialization (default, with
init_roundsand withrandom_init) and the protocol (ring,sy-rep-ringandrep-field), and read back the entries I wrote. With the fix, all of them compile and read back correctly, including the first two snippets with all three protocols, and so doesRecursiveCircuitIndexStructurewithsbits. For the third snippet, the compiler now refuses primes of 80 and 81 bits withrequired bit length 80 too much, as it does for any 80-bit value, instead of computing a wrong result. With an 82-bit prime, it reads back correctly.Without
--prime, programs that compiled before, includingoram_tutorial,dijkstra_example,gale-shapley_tutorialandtest_path_oblivious_heap, compile to the same bytecode. The only exception is on prime fields, where the minimum prime length that a program declares withreqblcan now be larger, because it is computed from the longest word rather than fromused_bits.